package com.easywb.consumer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;


@Component
public class Consumer {
    @Value("${server.port}")
    private String serverPort;

    @StreamListener("my_msg")
    public void listener(String msg) {
        System.out.println(msg);
        JSONObject jsonObject = JSON.parseObject(msg);
        System.out.println("消费者获取生产消息:" + jsonObject.get("sa") + ",端口号:" + serverPort);
    }

    @StreamListener("my_testns")
    public void listeners(String msg) {
        System.out.println(msg);
    }

}
